<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //返回数组元素索引方法
        var arr = ['red', 'black', 'green', 'pink', 'red'];
        console.log(arr.indexOf('red'));
        console.log(arr.lastIndexOf('red'));
    </script>
</head>

<body>

</body>

</html>